package com.elguile.laptop.vista;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JDesktopPane;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import com.elguile.laptop.baseDatos.RepositorioVenta;
import com.elguile.laptop.casoDeUso.RegistroDeVenta;
import com.elguile.laptop.entidades.RelojVerdadero;
import javax.swing.AbstractAction;
import javax.swing.Action;

public class FrmPrincipal extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JInternalFrame frmVenta = null;
	private JInternalFrame frmReporteVenta = null;
	private final JDesktopPane desktopPane = new JDesktopPane();


	public FrmPrincipal() {

		setTitle("Reparcion El Gile");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		setExtendedState(JFrame.MAXIMIZED_BOTH);
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);

		JMenu mnNewMenu = new JMenu("Procesos");
		menuBar.add(mnNewMenu);

		JMenuItem mntmNewMenuItem = new JMenuItem("Venta");
		mnNewMenu.add(mntmNewMenuItem);
		mntmNewMenuItem.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				frmVenta.setVisible(true);
			}
		});

		JMenu mnNewMenu_1 = new JMenu("Reporte");
		menuBar.add(mnNewMenu_1);

		JMenuItem mntmReporteventa = new JMenuItem("Reporte de Venta");
		mntmReporteventa.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frmReporteVenta.setVisible(true);
			}
		});
		mnNewMenu_1.add(mntmReporteventa);
		contentPane = new JPanel();
		contentPane.setBorder(null);
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));

		contentPane.add(desktopPane, BorderLayout.CENTER);

	}

	public void addPanVenta(PanVenta panVenta) {
		this.frmVenta = creaInternalFrame(panVenta, "venta");
		desktopPane.add(frmVenta);
	}

	public void addPanReporteVenta(PanReporteVenta panReporteVenta) {
		this.frmReporteVenta = creaInternalFrame(panReporteVenta,
				"reporteVenta");
		desktopPane.add(frmReporteVenta);
	}

	private JInternalFrame creaInternalFrame(JPanel panel, String titulo) {
		JInternalFrame frmVenta = new JInternalFrame(titulo, true, true, true,
				true);
		frmVenta.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
		frmVenta.getContentPane().setLayout(new BorderLayout());
		frmVenta.getContentPane().add(panel, BorderLayout.CENTER);
		frmVenta.pack();
		return frmVenta;
	}

	
}
